<?php
/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class MessageCollectionLog {
			
	// Instance
	private static $instance = null;
	
	private $messageCollection;
	
	/**
	 * Constructeur priv�
	 */
	private function MessageCollectionLog() {
		$this->messageCollection = array();
	}
	
	/**
	 * Renvoie l'instance du singleton
	 */
	public static function getInstance() {
		if (!isset(self::$instance)) {
			$c = __CLASS__;
			self::$instance = new $c;
		}
		
		return self::$instance;
	}
	
	/**
	 * Permet d'ajouter un message
	 * @param MessageLog $mess
	 */
	public function addMessage(MessageLog $mess) {
		$this->messageCollection[] = $mess;
	}
	
	/**
	 * Renvoie le nombre de messages
	 */
	public function countMessages() {
		return sizeOf($this->messageCollection);
	}
	
	/**
	 * Renvoie les messages de logs
	 */
	public function getMessage() {
		if (sizeOf($this->messageCollection) > 0)
		{
			$str = "<table style=\\\"width:100%;\\\">";
			foreach ($this->messageCollection as $mess) $str.= $mess->viewLog();
			$str.= "</table>";
			return $str;
		}
		return null;
	}
}

/**
 * Enter description here ...
 * @author Micou13630
 *
 */
class MessageLog {
	const TYPE_INFO  	= "info";
	const TYPE_WARN		= "warn";
	const TYPE_ERROR 	= "error";
	const TYPE_PROFILE 	= "profile";
	
	private $type;
	private $classname;
	private $message;
	
	/**
	 * Constructeur
	 * @param unknown_type $type
	 * @param unknown_type $message
	 */
	public function MessageLog($type, $classname, $message) {
		$this->type 		= $type;
		$this->classname	= $classname;
		$this->message 		= $message;
	}
	
	public function viewLog() {
		$str = '<tr style=background:#eee;><td width=20 align=center><img src='.Config::getParams()->PATH_GLYPHE.'res/img/'.$this->type.'.png></td><td style=font-size:10px;>'.$this->classname.'</td><td style=font-size:10px;>'.$this->message.'</td></tr>';
		return $str;
	}
}
?>